The not operator flips a boolean value.
public static boolean compare(boolean val1, boolean val2) {
boolean result = !(val1 || val2);
return result;
}
| Function Call | Return Value | |||
|---|---|---|---|---|
| compare(true, true) | → | |||
| compare(true, false) | → | |||
| compare(false, true) | → | |||
| compare(false, false) | → | |||
Experiment with this code on Gitpod.io